package com.tl.web.controller.app;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.tl.common.annotation.Log;
import com.tl.common.core.controller.BaseController;
import com.tl.common.core.domain.AjaxResult;
import com.tl.common.enums.BusinessType;
import com.tl.app.domain.AppGradeUser;
import com.tl.app.service.IAppGradeUserService;
import com.tl.common.utils.poi.ExcelUtil;
import com.tl.common.core.page.TableDataInfo;

/**
 * 用户等级Controller
 * 
 * @author suhp
 * @date 2024-07-07
 */
@RestController
@RequestMapping("/app/gradeUser")
public class AppGradeUserController extends BaseController
{
    @Autowired
    private IAppGradeUserService appGradeUserService;

    /**
     * 查询用户等级列表
     */
    @GetMapping("/list")
    public TableDataInfo list(AppGradeUser appGradeUser)
    {
        startPage();
        List<AppGradeUser> list = appGradeUserService.selectAppGradeUserList(appGradeUser);
        return getDataTable(list);
    }

    /**
     * 导出用户等级列表
     */
    @Log(title = "用户等级", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, AppGradeUser appGradeUser)
    {
        List<AppGradeUser> list = appGradeUserService.selectAppGradeUserList(appGradeUser);
        ExcelUtil<AppGradeUser> util = new ExcelUtil<AppGradeUser>(AppGradeUser.class);
        util.exportExcel(response, list, "用户等级数据");
    }

    /**
     * 获取用户等级详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(appGradeUserService.selectAppGradeUserById(id));
    }

    /**
     * 新增用户等级
     */
    @Log(title = "用户等级", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AppGradeUser appGradeUser)
    {
        return toAjax(appGradeUserService.insertAppGradeUser(appGradeUser));
    }

    /**
     * 修改用户等级
     */
    @Log(title = "用户等级", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AppGradeUser appGradeUser)
    {
        return toAjax(appGradeUserService.updateAppGradeUser(appGradeUser));
    }

    /**
     * 删除用户等级
     */
    @Log(title = "用户等级", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(appGradeUserService.deleteAppGradeUserByIds(ids));
    }
}
